<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>文章</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
        html,
        body {
            font-size: 14px;
            height: 100%;
            background-color: #fff;
        }

        header {
            position: fixed;
            top: 0;
            width: 100%;
            height: 75px;
            text-align: left;
            background-color: #fff;
            border-bottom: 1px solid #f2f2f2;
        }

        header .back {
            position: relative;
            margin-top: 38px;
            width: 100%;
            height: 1.5rem;
            text-align: center;
        }

        .back img {
            position: absolute;
            left: 1rem;
            width: 1.5rem;
            height: 1.5rem;
            vertical-align: middle;
        }

        main {
            padding-top: 75px;
        }

        main .title {
            padding: 1rem;
            box-sizing: border-box;
        }

        .title h2 {
            margin-bottom: 0.5rem;
        }

        .title span:nth-child(2) {
            color: #2b4b6b;
            margin-right: 1rem;
        }

        .title span:nth-child(3) {
            color: #555;
        }

        main .article {
            padding: 1rem;
            box-sizing: border-box;
        }

        .article p {
            text-indent: 2em;
            line-height: 1.5;
        }

        .article img {
            width: 100%;
            vertical-align: top;
            margin: 1rem 0;
            border-radius: 0.35rem;
        }

        .warn {
            padding: 1rem;
            color: #666;
            text-align: center;
        }

        footer {
            height: 10rem;
            padding: 2rem;
            box-sizing: border-box;
        }

        footer img {
            width: 100%;
            height: 100%;
            border-radius: 0.35rem;
        }
    </style>
</head>

<body>
    <header>
        <div class="back">
            <img src="../image/icon/back.png" alt="" onclick="api.closeWin()">
            <span></span>
        </div>
    </header>
    <main>

    </main>
</body>
<script type="text/template" id="article">
    {{~it.items:value:index}}
    <div class="title">
        <h2>{{=value.title}}</h2>
        <span>{{=value.author}}</span><span>{{=value.date}}</span>
    </div>
    <div class="article">{{=value.content}}</div>
    <div class="warn">---资源来源于互联网，本文只用作学习。---</div>
    <footer>
        <img src="../image/article/footer1.gif" alt="">
    </footer>
    {{~}}
</script>
<script type="text/javascript" src="../script/api.js"></script>
<script src="../script/jquery-1.11.3.min.js" charset="utf-8"></script>
<script src="../script/doT.min.js" charset="utf-8"></script>
<script type="text/javascript">
    apiready = function() {
        getTitle();
        getarticle();
    };

    function getarticle() {
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '努力加载中...',
            modal: false
        });
        api.ajax({
            url: 'http://122.112.138.133/wangt/jianzhi/queryArticle.com',
            method: 'post',
            data: {
                body: {
                    type: api.pageParam.title
                }
            }
        }, function(ret, err) {
            if (ret) {
                var data = ret.data.records.filter(function(x, i) {
                    return x.type == api.pageParam.title
                })
                $('main').append(parttime_render('article', data));
                api.hideProgress();
            }
        });
    }

    function getTitle() {
        var title = api.pageParam.title;
        $('.back').find('span').text(title);
    }

    function parttime_render(id, elements, options) {
        var options = options || {};
        var elementObj = doT.template($api.byId(id).innerHTML);
        var elementData = $.extend({
            items: elements
        }, options);
        return elementObj(elementData);
    }
</script>

</html>
